package com.example.houduan.Service.Impl;

import com.example.houduan.Mapper.RequiredMaterialMapper;
import com.example.houduan.Pojo.RequiredMaterial;
import com.example.houduan.Service.RequiredMaterialService;
import com.example.houduan.Utils.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RequiredMaterialServiceImpl implements RequiredMaterialService {

    @Autowired
    RequiredMaterialMapper requiredMaterialMapper;

    @Override
    public PageModel getRequiredMaterialPage(int num, int size) {
        int count = requiredMaterialMapper.selectRequiredMaterialCount();
        PageModel pm = new PageModel(num,count,size);
        pm.setList(requiredMaterialMapper.selectRequiredMaterialLimit((num-1)*size,size));
        return pm;
    }

    @Override
    public int deleteRequiredMaterial(Integer meterial_id) {
        return requiredMaterialMapper.deleteRequiredMaterial(meterial_id);
    }

    @Override
    public int updateRequiredMaterial(RequiredMaterial requiredMaterial) {
        return requiredMaterialMapper.updateRequiredMaterial(requiredMaterial);
    }

    @Override
    public int addRequiredMaterial(RequiredMaterial requiredMaterial) {
        return requiredMaterialMapper.insertRequiredMaterial(requiredMaterial);
    }
    
    @Override
    public List<RequiredMaterial> getRequiredMaterialByConditions(Integer meterial_id, String title, String policy_title) {
        return requiredMaterialMapper.selectRequiredMaterialByConditions(meterial_id, title, policy_title);
    }
} 